/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.raflik.queryxml.ui.cellrenderer;

import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JList;
import pl.raflik.queryxml.langservice.QueryLanguage;
import pl.raflik.queryxml.ui.SelectableComboBoxRenderer;

/**
 *
 * @author raflik
 */
public class LanguageListCellRenderer extends SelectableComboBoxRenderer {

    @Override
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

        if (value instanceof QueryLanguage) {
            final QueryLanguage ql = (QueryLanguage) value;
            final String lang = ql.supportedLanguage();
            label.setText(lang);
            label.setToolTipText(lang);
        }
        
        return label;
    }
}
